<?php
	class phpGrowler {
		
		/*
		 * Usage: notify('report', 'its all messed up broken!!', 'dunno yet what to do with icons', 'Fuckin´ Radioactive Bullshit-Statusmessage');
		 */
		
		/**
		 * TODO:
		 * • notification icon won't show up, only icon for filetype appears
		 */
		
		function notify($name = NULL, $title, $message, $icon = NULL, $severity = 'Normal') {
			$command 		= "/usr/local/bin/growlnotify ";
			
			if(isset($title) && isset($message)) { // title & message
				$title 		= $title;
				$message 	= $message;
				$params 	.= escapeshellcmd("-t '{$title}' -m '{$message}' ");
			}
			
			if ($name != NULL) {
				$params 		.= escapeshellcmd("-n '{$name}' ");
			}
			else {
				$params			.= escapeshellcmd("-n 'phpGrowler' ");
			}

			if ($icon != NULL) {
				$params		.= escapeshellcmd("-i 'png' -I '{$icon}' ");
			}

			if ($severity !== 'Normal') {
				$params 	.= escapeshellcmd("-s {$severity}");
			}

			passthru($command.$params);
			
			return true;
		}
	}
?>